<?php $this->renderPartial('/admin/menu/content');?>
<h4><?php echo Yii::t('helpdesk','Documents'); ?></h4><br>
<?php
foreach(Yii::app()->user->getFlashes() as $key => $message){
	echo '<div class="'.$key.'"><p>'.$message."</p></div>\n";
}
?>
<a href="/admin/documents"><i title="go back" class="fa fa-arrow-left"></i> <?php echo Yii::t('helpdesk','Go back'); ?></a>
<form id="create-ticket" class="form-horizontal" enctype="multipart/form-data" method="post">
<table style="width:100%;" class="table table-bordered table-nonfluid table-condensed">
	<tbody>
    <tr>
    	<td><?php echo Yii::t('helpdesk','Folder'); ?></td>
        <td>
        	<select id="folder" name="folder[]" class="form-control" required>
            	<option value="">-- <?php echo Yii::t('helpdesk','Choose'); ?> --</option>
				<?php foreach($arrFolders as $R): ?>
                <option value="<?php echo $R['category_id']; ?>" <?php if( isset($document['post_category_id']) && in_array($R['category_id'], $document['post_category_id'])):?>selected=""<?php endif; ?>> <?php for($i=0; $i<$R['category_level']; $i++): echo '&nbsp;&nbsp;&nbsp;&nbsp;'; endfor;?>  <?php echo $R['category_name']; ?></option>
				<?php endforeach; ?>
            </select>
        </td>
   	</tr>
    
    <tr>
    	<td><?php echo Yii::t('helpdesk','Title'); ?></td>
        <td>
        	<input type="text" required="" class="form-control" id="title" name="title" style="width:100%" value="<?php echo isset($document['post_title'])?$document['post_title']:null; ?>">
        </td>
   	</tr>
    
	<tr>
		<td valign="top"><?php echo Yii::t('helpdesk','Content'); ?></td>
		<td><textarea style="width: 100%" name="body" rows="5" class="form-control"><?php echo isset($document['post_body'])?$document['post_body']:null; ?></textarea></td>
	</tr>
		
    <tr>
		<td valign="top"><?php echo Yii::t('helpdesk','Attachment'); ?></td>
		<td>
            <?php if(isset($document['fields']['article-attachment'])): ?>
            	<?php echo '<a href="'.UPLOADS_URL.'/'.$document['fields']['article-attachment'].'" title="Download" target="_blank">'.pathinfo($document['fields']['article-attachment'], PATHINFO_BASENAME).'</a>' ?><br>
			<?php endif; ?>

        	<input type="file" name="attach" id="attach"> <small>(<?php echo Yii::t('helpdesk','Max'); ?>: <?php echo ini_get("upload_max_filesize"); ?>) <br> <?php echo Yii::t('helpdesk','If you\'d like to upload a bunch of files please combine them into one compressed file (such as zip, rar...)'); ?></small>
        </td>
	</tr>

    <tr>
    	<td valign="top"><?php echo Yii::t('helpdesk','Options'); ?></td>
		<td>
        	<div><label style="font-weight:normal;"><input type="checkbox" id="privacy" name="privacy" value="2" <?php if($document['post_privacy'] == '2'): ?>checked<?php endif; ?>> <?php echo Yii::t('helpdesk','Enable file download'); ?></label></div>
			<div><label style="font-weight:normal;"><input type="checkbox" id="status" name="status" value="1" <?php if(empty($document) || $document['post_status'] == '1'): ?>checked<?php endif; ?>> <?php echo Yii::t('helpdesk','Published'); ?></label></div>
        </td>
	</tr>  
</tbody>
</table>

<input type="submit" class="btn btn-large btn-primary" value="<?php echo !empty($intId)?Yii::t('helpdesk','Update'):Yii::t('helpdesk','Add new'); ?>">
</form>
<script type="text/javascript" src="libs/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="js/ckeditor_configs.js"></script>
<script type="text/javascript">
$(function(){
	CKEDITOR.replace( 'body', ck_full_editor);
});
</script>